import { Pipe, PipeTransform } from '@angular/core';

import { NameLabel } from '@core/base';

@Pipe({
  name: 'nameLabelFilterName'
})
export class NameLabelFilterNamePipe implements PipeTransform {
  transform(arr: NameLabel[], name: string): string {
    if (Array.isArray(arr) && name) {
      const data = arr.find(item => item.name === name);
      if (data) {
        return data.label;
      }
    }
    return name;
  }
}
